package com.yongqi.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.yongqi.model.News;
import com.yongqi.pub.DateFormat;
import com.yongqi.service.NewsService;

@Controller
public class WelcomeController {
	@Autowired
	NewsService newsService;
	/*
	 * 指向欢迎首页
	 */
	@RequestMapping("/welcome")
	public String welcomePage() {
		return "welcome";
	}
	
	/*
	 * 指向欢迎页面新闻
	 */
	@RequestMapping("/welcome/news")
	public String welcomeNewsPage(Model model,@RequestParam("mark") String mark) {
		System.out.println(mark+"------------------------------------------");
		String date = DateFormat.dateFormate5();
		Map<String , String> map = new HashMap<String,String>();
		map.put("mark", mark);
		map.put("date", date);
		List<News> newsList = newsService.queryNews(map);
		model.addAttribute("news", newsList);
		return "news";
	}
}
